package com.cskaoyan._12io._01bytestream._03bufferedstream;

import java.io.*;

/**
 * @author Macro_Ray
 * @since 2024/3/26 21:00
 */
/*
  需求: 利用字节缓冲流拷贝文件
        字节缓冲输入流的构造方法:
            public BufferedInputstream(Inputstream is)
        字节缓冲输出流的构造方法:
            public BufferedOutputstream(Outputstream os)*/
public class Demo2 {
    public static void main(String[] args) throws IOException {
        // 1.创建缓冲流对象
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("Day17_Code\\a.txt"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("a2.txt"));
        // 2.循环读取
        int len;
        byte[] buffer = new byte[1024];
        while ((len = bis.read(buffer)) != -1) {
            bos.write(buffer, 0, len);
        }
        // 3.关闭流
        bos.close();
        bis.close();
    }
}
